<template>
	<view class="content">
		<u-navbar title="我的动态" :border-bottom="false" back-icon-color="#ffffff" title-color="#fff"
			:background="{backgroundColor:'#2A2931'}"></u-navbar>
		<view class="list">
			<dy-item v-for="(item,index) in dylist" @zan="zan(index)" @dyopsshow="dyopsshow(index)" :item="item"></dy-item>
		</view>
		<u-action-sheet :list="dyops" @click="dyopclick" v-model="dyopshow"></u-action-sheet>
	</view>
</template>

<script>
	import dyItem from '@/components/dy-item.vue'
	export default {
		components:{
			dyItem
		},
		data() {
			return {
				HOSTURL: this.$HOSTURL,
				page: 0,
				dyopshow: false,
				dyopidx: -1,
				dyops: [{
					text: '删除'
				}],
				dylist: [],
				themeObj: []
			}
		},
		onLoad() {
			this.getdy()
		},
		methods: {
			async dyopclick(index) {
				const {data:res} = await this.$Request({
					url: 'api/Member/delDymanic',
					data: {
						id: this.dylist[this.dyopidx].dy_id
					}
				})
				this.$u.toast(res.msg);
				console.log('删除');
				console.log(res);
				if (res && res.code == 200) {
					this.dylist.splice(this.dyopidx, 1);
					this.dyopidx = -1
				}
			},
			dyopsshow(idx) {
				this.dyopidx = idx
				this.dyopshow = true
			},
			async zan(index) {
				const {
					data: res
				} = await this.$Request({
					url: 'apis/home/Dymanic/thumbsup',
					data: {
						type: this.dylist[index].isthumbsup == 1 ? 2 : 1,
						dy_id: this.dylist[index].dy_id,
						userid: this.$store.state.userid
					}
				})
				if (res.code == 200) {
					this.dylist[index].isthumbsup = this.dylist[index].isthumbsup == 1 ? 0 : 1
					this.dylist[index].isthumbsup == 1 ? this.dylist[index].num++ : this.dylist[index].num--
				}
			},
			async getdy() {
				const {
					data: res
				} = await this.$Request({
					url: 'apis/home/Dymanic/selflist',
					data: {
						userid: this.$store.state.userid,
						to_user: this.$store.state.userid,
						pagecount: 10,
						pagesize: 10,
						page: this.page
					}
				})
				this.dylist = this.dylist.concat(res.result)
			}
		},
		onReachBottom() {
			this.page++
			this.getdy()
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #2A2931;
		min-height: 100vh;

		.list {

		}

	}
</style>
